# Contributor: Jonas <3426-spameier@users.gitlab.alpinelinux.org>
# Maintainer: Jonas <3426-spameier@users.gitlab.alpinelinux.org>
pkgname=swtpm
pkgver=0.9.0
pkgrel=0
pkgdesc="Libtpms-based TPM emulator with socket, character device, and Linux CUSE interface"
url="https://github.com/stefanberger/swtpm"
arch="all"
license="BSD-3-Clause"
makedepends="autoconf automake bash expect gawk gnutls gnutls-dev gnutls-utils
	json-glib-dev libseccomp-dev libtasn1-dev libtool libtpms-dev openssl-dev>3
	python3 socat
	"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/stefanberger/swtpm/archive/v$pkgver.tar.gz"
options="!check" # needs /dev/tpm0 among others

prepare() {
	default_prepare
	NOCONFIGURE=1 ./autogen.sh
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--libdir=/usr/lib \
		--with-openssl \
		--with-tss-user=root \
		--with-tss-group=root
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
4f1723679b85218e80ea6aacdffa687e541ee309ddab9bcb8d8e5aa0b461ee431c880f2e300f1dcae112646f3636593005a342ee0cb762ec115aa599369e111c  swtpm-0.9.0.tar.gz
"
